Override phpunit assertTag method to stop errors
authoraddshore <addshorewiki@gmail.com>
Sun, 17 Aug 2014 21:38:07 +0000 (22:38 +0100)
committerOri.livneh <ori@wikimedia.org>
Sun, 17 Aug 2014 21:41:18 +0000 (21:41 +0000)
This method throws a deperecation error in phpunit
that we dont want to see (and dont want to break
travis tests).

Nothing this method uses is beign deprecated thus
we can override the method and not need to worry
about the error or it vanishing in the future!

Bug: 69505
Change-Id: I0eb63be390b4fdf416635dd8e8a2ad94615e6a47

tests/phpunit/MediaWikiTestCase.php

index 1fbc7a2..873d979 100644 (file)
@@ -1109,4 +1109,24 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
 
                $this->assertEmpty( $errors, implode( "\n", $errors ) );
        }
+
+       /**
+        * Note: we are overriding this method to remove the deprecated error
+        * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=69505
+        * @see https://github.com/sebastianbergmann/phpunit/issues/1292
+        *
+        * @param array $matcher
+        * @param string $actual
+        * @param string $message
+        * @param bool $isHtml
+        */
+       public static function assertTag($matcher, $actual, $message = '', $isHtml = true) {
+               //trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
+
+               $dom     = PHPUnit_Util_XML::load($actual, $isHtml);
+               $tags    = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml);
+               $matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
+
+               self::assertTrue($matched, $message);
+       }
 }